#include "qwtcounterhost.h"

#include "../../libs/qwt/qwt_counter.h"
#include "../../libs/shared/qhostfactory.h"
#include "../../libs/shared/qpropertyfactory.h"
#include "../../libs/shared/qcommonstruct.h"
#include "../../libs/shared/property/qabstractproperty.h"
#include "../../libs/qwt/qwt_dial_needle.h"

QwtCounterHost::QwtCounterHost(QAbstractHost *parent):
    QWidgetHost(parent)
{
    setProperty("accept_drop",false);
}

void QwtCounterHost::init_property()
{
    QWidgetHost::init_property();

    remove_property("cursor");
    remove_property("enabled");
    remove_property("focusPolicy");
    remove_property("background");
    remove_property("border");
    remove_property("toolTip");
    remove_property("mouseMove");
    remove_property("mousePress");
    remove_property("mouseRelease");
    remove_property("doubleClick");

    QAbstractProperty* pro;

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","value");
        pro->set_attribute("show_name",tr("Value"));
        pro->set_attribute("group","Attributes");
        insert_property(pro,2);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","numButtons");
        pro->set_attribute("show_name",tr("Buttons"));
        pro->set_attribute("group","Attributes");
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","stepButton1");
        pro->set_attribute("show_name",tr("Button1 Step"));
        pro->set_attribute("group","Attributes");
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","stepButton2");
        pro->set_attribute("show_name",tr("Button2 Step"));
        pro->set_attribute("group","Attributes");
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","stepButton3");
        pro->set_attribute("show_name",tr("Button3 Step"));
        pro->set_attribute("group","Attributes");
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","minimum");
        pro->set_attribute("show_name",tr("Minimum"));
        pro->set_attribute("group","Attributes");
        insert_property(pro,2);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","maximum");
        pro->set_attribute("show_name",tr("Maximum"));
        pro->set_attribute("group","Attributes");
        insert_property(pro,2);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","singleStep");
        pro->set_attribute("show_name",tr("Single Step"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute("count",6);
        insert_property(pro,2);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","readOnly");
        pro->set_attribute("show_name",tr("ReadOnly"));
        pro->set_attribute("group","Attributes");
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","wrapping");
        pro->set_attribute("show_name",tr("Wrapping"));
        pro->set_attribute("group","Attributes");
        insert_property(pro);
    }


    set_property_value("geometry",QRect(0,0,400,40));
}

QString QwtCounterHost::get_show_name()
{
    return tr("QWT Counter");
}

QString QwtCounterHost::get_show_group()
{
    return tr("QWT Widgets");
}

QString QwtCounterHost::get_show_icon()
{
    return ":/images/icon_compass_alt.png";
}

void QwtCounterHost::create_object()
{
    m_object=new QwtCounter;
    m_object->setObjectName("counter");
}

qRegisterHost("qwt.counter",QwtCounterHost,6060)
